<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //不能出现数组里的敏感词 出现返回false 
    let keys= ["天", "上", "地", "下"]
    let str = "发顺丰撒旦黑上暗时代阿下斯顿阿斯顿"
    for (let i = 0; i < keys.length; i++) {
        let reg = new RegExp(keys[i], "ig")
        if (reg.test(str)) {
            console.log("有敏感词" + keys[i]);
            str = str.replace(reg, "*")
        }
    }
    console.log(str);
    
</script>
</html>